﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XAsset;

public class LoadDialPanel : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
        if (!Assets.Initialize())
        {
            Debug.LogError("Assets.Initialize falied.");
        }
        //StartCoroutine(LoadAsync());
        var obj = LoadPanel() as GameObject;
        obj.transform.SetParent(this.transform);
        obj.transform.localScale = Vector3.one;
        obj.transform.localPosition = Vector3.zero;
    }

    Object LoadPanel()
    {
        string assetPath = "Assets/SampleAssets/UIMenuPanel.prefab";
        Debug.Log("------------------ Assets.Load ------------------");
        var asset = Assets.Load<GameObject>(assetPath);
        if (asset != null && asset.asset != null)
        {
            var go = Instantiate(asset.asset);
            //Object.Destroy(go, 1);
            return go;
        }
        asset.Unload();
        asset = null;
        return null;
    }
}
